package org.example.map;

import java.util.Comparator;
import java.util.Scanner;
import java.util.TreeSet;

public class TestTreeSet {
    public static void main(String[] args) {
        TreeSet<Integer> set1 = new TreeSet<>(new Comparator<Integer>() {
            @Override
            public int compare(Integer o1, Integer o2) {
                return o2-o1;
            }
        });
        Scanner input  = new Scanner(System.in);
        while(true) {

            int n = input.nextInt();
            if(n==1000){
                break;
            }
            set1.add(n);
            if (set1.size() > 5) {
                set1.pollLast();
            }
        }
        System.out.println(set1);
    }
}
